﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace DevExpress.Demos.DemoCenter
{
    public partial class BlankControl : DevExpress.XtraEditors.XtraUserControl
    {
        LabelEx lblEx = null;
        LabelEx lblEx2 = null;
        MyPictureBox myPictureBox = null;
        MemoEdit memoEdit = null;

        public BlankControl()
        {
            InitializeComponent();
            //添加控件
            AddQuestionsControl();
        }


        /// <summary>
        /// 添加控件
        /// </summary>
        public void AddQuestionsControl()
        {
            lblEx = new LabelEx();
            lblEx.AutoResizeParent = false;
            lblEx.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            lblEx.Location = new System.Drawing.Point(19, 9);
            lblEx.Name = "lblEx";
            lblEx.Width = 560;
            lblEx.Text = "一、生活资料是人们利用自然资源和劳动工具通过劳动_________(生产)出来的。";
            lblEx.Click += new EventHandler(lblEx_Click);
            this.Controls.Add(lblEx);

            myPictureBox = new MyPictureBox();
            myPictureBox.Location = new System.Drawing.Point(19, lblEx.Location.Y+lblEx.Height+5);
            myPictureBox.Name = "myPictureBox";
            myPictureBox.Properties.Appearance.BackColor = System.Drawing.Color.Transparent;
            myPictureBox.Properties.Appearance.Options.UseBackColor = true;
            myPictureBox.Properties.Appearance.Options.UseBorderColor = true;
            myPictureBox.Properties.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.Simple;
            myPictureBox.Size = new System.Drawing.Size(200, 160);
            myPictureBox.TabIndex = 12;
            myPictureBox.MouseEnter += new System.EventHandler(this.myPictureBox3_MouseEnter);
            myPictureBox.MouseLeave += new System.EventHandler(this.myPictureBox3_MouseLeave);
           
            myPictureBox.Image = Image.FromFile(@"form-main-bg.png");
            this.Controls.Add(myPictureBox);

            lblEx2 = new LabelEx();
            lblEx2.AutoResizeParent = false;
            lblEx2.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            lblEx2.Location = new System.Drawing.Point(19, myPictureBox.Location.Y+myPictureBox.Height+5);
            lblEx2.Name = "lblEx2";
            lblEx2.Width = 560;
            lblEx2.Text = "请将空白处应填入内容填入到下面的文本框中:";
            lblEx2.Click += new EventHandler(lblEx_Click);
            this.Controls.Add(lblEx2);

            memoEdit = new MemoEdit();
            memoEdit.Location = new System.Drawing.Point(19, lblEx2.Location.Y+lblEx2.Height+5);
            memoEdit.Name = "memoEdit";
            memoEdit.Properties.Appearance.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            memoEdit.Properties.Appearance.Options.UseFont = true;
            memoEdit.Properties.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.Simple;
            memoEdit.Properties.Appearance.Options.UseBorderColor = true;
            memoEdit.Size = new System.Drawing.Size(560, 25);
            memoEdit.MouseEnter+=new EventHandler(memoEdit_MouseEnter);
            memoEdit.MouseLeave+=new EventHandler(memoEdit_MouseLeave);

            this.Controls.Add(memoEdit);
            this.Height = memoEdit.Location.Y + memoEdit.Height;
        }

        void lblEx_Click(object sender, EventArgs e)
        {
            this.lblEx.Parent.Parent.Focus();
        }

        private void myPictureBox3_MouseEnter(object sender, EventArgs e)
        {
            this.myPictureBox.Properties.Appearance.BorderColor = Color.FromArgb(255, 188, 98);
            this.myPictureBox.Cursor = Cursors.Hand;
        }

        private void myPictureBox3_MouseLeave(object sender, EventArgs e)
        {
            this.myPictureBox.Properties.Appearance.BorderColor = Color.White;
        }

        private void memoEdit_MouseEnter(object sender, EventArgs e)
        {
            this.memoEdit.Properties.AppearanceReadOnly.BorderColor = Color.FromArgb(255, 188, 98);
        }

        private void memoEdit_MouseLeave(object sender, EventArgs e)
        {
            this.memoEdit.Properties.AppearanceReadOnly.BorderColor = Color.White;
        }

        private void AnswerControl_Click(object sender, EventArgs e)
        {
            this.Parent.Focus();
        }


    }
}
